/*
* createTime：2019/10/25
* author：junyong.hong
* description:
*/
<template>
    <div class="index">
        <img src="../../resource/assets/img/header.png" class="header" alt="">
        <div class="nickname" v-if="userInfo" v-text="userInfo.nickname"></div>
        <div class="btn-group">
            <button @click="share" class="btn">分享</button>
            <button @click="recharge" class="btn btn-primary">充值</button>
            <button @click="activity" class="btn">活动详情</button>
        </div>
    </div>
</template>
<script type="text/ecmascript-6">
    import API from './../api/index'

    export default {
        components: {},
        data() {
            return {
                userInfo: ''
            }
        },
        mounted() {
            if (this.$cookie.get('openId')) {
                this.getUserInfo()
            }
        },
        methods: {
            // 获取用户信息
            getUserInfo () {
                this.$http.get(API.getUserInfo).then((response) => {
                    let res = response.data
                    this.userInfo = res.data
                })
            },
            share () {
                alert('请点击右上角的三个点点点进行分享')
            },
            recharge () {
                this.$router.push('/pay')
            },
            activity () {
                this.$router.push('/activity')
            }
        }
    }
</script>
<style>
    .index{
        background-color:#FFC93A;
        height:100vh;
    }
    .btn-group{
        padding-top:.34rem;
        text-align:center;
    }
    .nickname{
        position:absolute;
        top:6rem;
        left: 50%;
        transform: translateX(-50%);
        font-size:18px;
    }
</style>